package com.market.cash.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/24 14:42
 * @Annotation：贷款申请 选择时间 适配器
 */
class CashRootApplyDaysAdapter(recyclerView: RecyclerView?) : CashRootRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.cash_apply_days_item) {
    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.textDay) //点击Item
    }

    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        val textDays = helper.getTextView(R.id.textDay)
        textDays.text = String.format(mContext.getString(R.string.loan_apply_days),model.optString("day"))

        if (model.optBoolean("isEnabled",true)){//可选
            if (model.optBoolean("isSelect",false)){
                textDays.setBackgroundResource(R.drawable.cash_radius_fill_435cfa_12)
                textDays.setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                textDays.setBackgroundResource(R.drawable.cash_radius_fill_f0f0f0_12)
                textDays.setTextColor(Color.parseColor("#6C6C6C"))
            }
        } else {//不可选
            textDays.setBackgroundResource(R.drawable.cash_radius_fill_f0f0f0_12)
            textDays.setTextColor(Color.parseColor("#6C6C6C"))
        }
    }
}